﻿using RabbitMQ.Client.Events;
using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using RabbitBus;

namespace RabbitMQClient.DelayedMsg
{
    public class DelayedHostService
    {
        public class RabbitmqDelayedHostService
        {
           

            public RabbitmqDelayedHostService()
            {
                ConnectionFactory connectionfactory = CreateConnectionFactory.CreateRabbitMqConnectionFactory();
                IConnection connection = connectionfactory.CreateConnection();
                IModel channel = connection.CreateModel();
                //交换机名称
                var exchangeName = "exchangeDelayed";
                var queueName = "delay_queueName";
                var routingkey = "delay.delay";
                var argMaps = new Dictionary<string, object>() { { "x-delayed-type", "topic" } };
                channel.ExchangeDeclare(exchange: exchangeName, type: "x-delayed-message", true, false, argMaps);
                channel.QueueDeclare(queueName, true, false, false, argMaps);
                channel.QueueBind(queue: queueName, exchange: exchangeName, routingKey: routingkey);
                channel.BasicQos(0, 1, false);//声明为手动确认
            }

           

        }

    }
}
